<?php
namespace Home\Model;
use Think\Model;

/**
* Created by hanquan.
* User partner
* Date 2017/04/07
* Time 11:07
* ProvinceModel 省份模型类
*/
class ProvinceModel extends Model{
	
	private $Province = null;
	function __construct(){
		$this->Province = M('Province');
	}

	/**
	 * get_province_lib 查询省份库列表
	 * @return array 二维数组
	 */
	public function get_province_lib(){
		return $this->Province->table('province_lib')->select();
	}

	/**
	 * get_province 查询省份列表
	 * @return array 二维数组
	 */
	public function get_province(){
		$condition['a.m_status'] = 1;
		$condition['a.city_id'] = array('exp','=b.city_id');
		$condition['b.pid'] = array('exp','=c.pid');
		return $this->Province->field('c.pid,c.province')->table('mp_member a,mp_city b,mp_province c')->where($condition)->group('c.pid')->select();
	}

	/**
	 * set_province 插入省份
	 * @param array $data 省份数据
	 */
	public function set_province($data){
		return $this->Province->add($data);
	}
}